/*
	Simple Software Renderer (SSRenderer)
	Copyright (C) 2007 Piotr Orzechowski <piotr.orzechowski@gmail.com>

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
*/

#include "./SSRRenderTarget.h"

namespace ssr
{

SSRRenderTarget::SSRRenderTarget()
{
    m_bIsLocked = false;
    m_pColorSurface = NULL;
    m_pAccumulationSurface = NULL;
}

SSRRenderTarget::~SSRRenderTarget()
{
    SSR_RELEASE(m_pColorSurface);
    SSR_RELEASE(m_pAccumulationSurface);
    m_bIsLocked = false;
}

SSRRenderTarget* SSRRenderTarget::CreateTarget(u32 width, u32 height)
{
    SSRRenderTarget *pTarget = new SSRRenderTarget();

    pTarget->m_pColorSurface = SSRSurface::CreateSurface(width, height);

    return pTarget;
}

void SSRRenderTarget::Lock()
{
    // Maybe I decide to put something in here someday
    m_bIsLocked = true;
}

void SSRRenderTarget::Unlock()
{
    // :-)
    m_bIsLocked = false;
}

bool SSRRenderTarget::IsLocked() const
{
    return m_bIsLocked;
}

SSRSurface* SSRRenderTarget::GetColorSurface()
{
    SSR_ADDREF(m_pColorSurface);
    return m_pColorSurface;
}

u32 SSRRenderTarget::GetWidth() const
{
    if (m_pColorSurface != NULL)
    {
        return m_pColorSurface->GetWidth();
    }
    else
    {
        return 0;
    }
}

u32 SSRRenderTarget::GetHeight() const
{
    if (m_pColorSurface != NULL)
    {
        return m_pColorSurface->GetHeight();
    }
    else
    {
        return 0;
    }
}

} // namespace

